package me.lc.hammerheads.core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import me.lc.hammerheads.entity.BGType;
import me.lc.hammerheads.entity.GameStageInfo;
import me.lc.hammerheads.entity.HoleLocationInfo;
import me.lc.hammerheads.util.GsonHelper;
import me.lc.hammerheads.util.ShareSettingUtil;

import com.google.gson.reflect.TypeToken;

public class StageManager {
	public static StageManager instance = new StageManager();
	// for unlimited
	public GameStageInfo umlimitStage;

	public List<GameStageInfo> stageInfoLst;
	public HashMap<String, Integer> stageScore;
	public int currentStage;

	public int goldCount;
	public int doubleHammerCount;
	public int bombCount;
	public int addHeartCount;
	public int allDwarfCount;
	/**
	 * 0关闭 1打开
	 */
	public int enableAudio;

	private static String stageScoreKey = "StageScores";
	private static String goldCountKey = "GoldCount";
	private static String doubleHammerKey = "doubleHammerCount";
	private static String bombCountKey = "bombCount";
	private static String addHeartCountKey = "addHeart";
	private static String enableAudioKey = "enableAudioKey";
	private static String allDwarfCountKey = "allDwarfCount";

	private StageManager() {

	}

	public GameStageInfo getCurrentInfo() {
		return stageInfoLst.get(currentStage);
	}

	public void saveGoldCount() {
		ShareSettingUtil.storeIntSetting(goldCountKey, goldCount);
	}

	public void saveToolsCount() {
		ShareSettingUtil.storeIntSetting(doubleHammerKey, doubleHammerCount);
		ShareSettingUtil.storeIntSetting(addHeartCountKey, addHeartCount);
		ShareSettingUtil.storeIntSetting(bombCountKey, bombCount);
	}

	public void init() {
		initUnlimit();
		initStagesInfos();
		initOldScores();
		initAssert();
		initAudioConfig();
	}

	public void saveAudioConfig() {
		ShareSettingUtil.storeIntSetting(enableAudioKey, enableAudio);
	}

	private void initAudioConfig() {
		enableAudio = ShareSettingUtil.getIntSetting(enableAudioKey, 1);
	}

	/**
	 * 载入金币和道具
	 */
	private void initAssert() {
		goldCount = ShareSettingUtil.getIntSetting(goldCountKey, 500);
		doubleHammerCount = ShareSettingUtil.getIntSetting(doubleHammerKey, 2);
		addHeartCount = ShareSettingUtil.getIntSetting(addHeartCountKey, 2);
		bombCount = ShareSettingUtil.getIntSetting(bombCountKey, 2);
	}

	/**
	 * 载入之前的得分
	 */
	private void initOldScores() {
		// TODO lc load stageScore;
		stageScore = new HashMap<String, Integer>();
		String value = ShareSettingUtil.getStringSetting(stageScoreKey);
		if (!value.equalsIgnoreCase("null")) {
			stageScore = (HashMap<String, Integer>) GsonHelper
					.getObjectbyJsonString(value,
							new TypeToken<HashMap<String, Integer>>() {
							}.getType());

			for (GameStageInfo stageInfo : stageInfoLst) {
				String key = stageInfo.getStageName();
				if (stageScore.containsKey(key)) {
					stageInfo.setScore(stageScore.get(key));
					stageInfo.setLocked(false);
				}
			}
		}
		allDwarfCount = ShareSettingUtil.getIntSetting(allDwarfCountKey, 0);
	}

	public void saveAllDwarfCount() {
		ShareSettingUtil.storeIntSetting(allDwarfCountKey, allDwarfCount);
	}

	/**
	 * 保存得分数据
	 */
	public void saveStageScore() {
		String value = GsonHelper.getJsonString(stageScore);
		ShareSettingUtil.storeStringSetting(stageScoreKey, value);
	}

	private void initStagesInfos() {

		stageInfoLst = new ArrayList<GameStageInfo>();
		// 1
		GameStageInfo s1 = new GameStageInfo();
		s1.setStageIndex(0);
		s1.setStageName("1");
		s1.setBgType(BGType.spring);
		List<HoleLocationInfo> holes = new ArrayList<HoleLocationInfo>();
		holes.add(new HoleLocationInfo(0.4583f, 0.665f));
		holes.add(new HoleLocationInfo(0.80208f, 0.56375f));
		holes.add(new HoleLocationInfo(0.7f, 0.3325f));
		holes.add(new HoleLocationInfo(0.3f, 0.255f));
		holes.add(new HoleLocationInfo(0.19375f, 0.48375f));
		s1.setHoles(holes);
		s1.setDwarfCount(25);
		s1.setDwarfInterval(1800);
		s1.setLocked(false);

		s1.setNormalPercentage(100);
		s1.setDoubleFemalePercentage(0);
		s1.setDoubleMalePercentage(0);
		s1.setBombPercentage(0);
		s1.setSilverPercentage(0);

		stageInfoLst.add(s1);

		// 2
		GameStageInfo s2 = new GameStageInfo();
		s2.setStageIndex(1);
		s2.setBgType(BGType.spring);
		s2.setStageName("2");
		List<HoleLocationInfo> holes2 = new ArrayList<HoleLocationInfo>();
		holes2.add(new HoleLocationInfo(0.5f, 1.0f - 0.3125f));
		holes2.add(new HoleLocationInfo(0.25f, 1.0f - 0.46375f));
		holes2.add(new HoleLocationInfo(0.75f, 1.0f - 0.46375f));
		holes2.add(new HoleLocationInfo(0.5f, 1.0f - 0.61875f));
		holes2.add(new HoleLocationInfo(0.25f, 1.0f - 0.7975f));
		holes2.add(new HoleLocationInfo(0.75f, 1.0f - 0.7975f));
		s2.setHoles(holes2);
		s2.setDwarfCount(40);
		s2.setDwarfInterval(1700);
		s2.setLocked(true);
		s2.setNormalPercentage(100);
		s2.setDoubleFemalePercentage(0);
		s2.setDoubleMalePercentage(0);
		s2.setBombPercentage(0);
		s2.setSilverPercentage(0);
		stageInfoLst.add(s2);

		// 3
		GameStageInfo s3 = new GameStageInfo();
		s3.setStageIndex(2);
		s3.setBgType(BGType.spring);
		s3.setStageName("3");
		List<HoleLocationInfo> holes3 = new ArrayList<HoleLocationInfo>();
		holes3.add(new HoleLocationInfo(0.6708f, 1.0f - 0.295f));
		holes3.add(new HoleLocationInfo(0.4708f, 1.0f - 0.455f));
		holes3.add(new HoleLocationInfo(0.19375f, 1.0f - 0.5575f));
		holes3.add(new HoleLocationInfo(0.775f, 1.0f - 0.5575f));
		holes3.add(new HoleLocationInfo(0.4708f, 1.0f - 0.6825f));
		holes3.add(new HoleLocationInfo(0.6708f, 1.0f - 0.825f));
		s3.setHoles(holes3);
		s3.setDwarfCount(42);
		s3.setDwarfInterval(1600);
		s3.setLocked(true);
		s3.setNormalPercentage(80);
		s3.setDoubleFemalePercentage(20);
		s3.setDoubleMalePercentage(0);
		s3.setBombPercentage(0);
		s3.setSilverPercentage(0);
		stageInfoLst.add(s3);

		// 4
		GameStageInfo s4 = new GameStageInfo();
		s4.setStageIndex(3);
		s4.setBgType(BGType.spring);
		s4.setStageName("4");
		List<HoleLocationInfo> holes4 = new ArrayList<HoleLocationInfo>();
		holes4.add(new HoleLocationInfo(0.323f, 1.0f - 0.335f));
		holes4.add(new HoleLocationInfo(0.735f, 1.0f - 0.335f));
		holes4.add(new HoleLocationInfo(0.1875f, 1.0f - 0.555f));
		holes4.add(new HoleLocationInfo(0.8375f, 1.0f - 0.5575f));
		holes4.add(new HoleLocationInfo(0.323f, 1.0f - 0.79125f));
		holes4.add(new HoleLocationInfo(0.735f, 1.0f - 0.79125f));
		s4.setHoles(holes4);
		s4.setDwarfCount(42);
		s4.setDwarfInterval(1600);
		s4.setLocked(true);
		s4.setNormalPercentage(60);
		s4.setDoubleFemalePercentage(40);
		s4.setDoubleMalePercentage(0);
		s4.setBombPercentage(0);
		s4.setSilverPercentage(0);
		stageInfoLst.add(s4);

		// 5
		GameStageInfo s5 = new GameStageInfo();
		s5.setStageIndex(4);
		s5.setBgType(BGType.spring);
		s5.setStageName("5");
		List<HoleLocationInfo> holes5 = new ArrayList<HoleLocationInfo>();
		holes5.add(new HoleLocationInfo(0.5f, 1.0f - 0.26875f));
		holes5.add(new HoleLocationInfo(0.325f, 1.0f - 0.42125f));
		holes5.add(new HoleLocationInfo(0.69375f, 1.0f - 0.42125f));
		holes5.add(new HoleLocationInfo(0.225f, 1.0f - 0.6475f));
		holes5.add(new HoleLocationInfo(0.7958f, 1.0f - 0.6475f));
		holes5.add(new HoleLocationInfo(0.5f, 1.0f - 0.82f));
		s5.setHoles(holes5);
		s5.setDwarfCount(43);
		s5.setDwarfInterval(1600);
		s5.setLocked(true);
		s5.setNormalPercentage(60);
		s5.setDoubleFemalePercentage(40);
		s5.setDoubleMalePercentage(0);
		s5.setBombPercentage(0);
		s5.setSilverPercentage(0);
		stageInfoLst.add(s5);

		// 6
		GameStageInfo s6 = new GameStageInfo();
		s6.setStageIndex(5);
		s6.setBgType(BGType.summer);
		s6.setStageName("6");
		List<HoleLocationInfo> holes6 = new ArrayList<HoleLocationInfo>();
		holes6.add(new HoleLocationInfo(getHoleX(81), getHoleY(283)));
		holes6.add(new HoleLocationInfo(getHoleX(243), getHoleY(283)));
		holes6.add(new HoleLocationInfo(getHoleX(396), getHoleY(283)));
		holes6.add(new HoleLocationInfo(getHoleX(240), getHoleY(450)));
		holes6.add(new HoleLocationInfo(getHoleX(100), getHoleY(587)));
		holes6.add(new HoleLocationInfo(getHoleX(370), getHoleY(587)));
		s6.setHoles(holes6);
		s6.setDwarfCount(25);
		s6.setDwarfInterval(1400);
		s6.setLocked(true);
		s6.setNormalPercentage(50);
		s6.setDoubleFemalePercentage(30);
		s6.setDoubleMalePercentage(20);
		s6.setBombPercentage(0);
		s6.setSilverPercentage(0);
		stageInfoLst.add(s6);

		// 7
		GameStageInfo s7 = new GameStageInfo();
		s7.setStageIndex(6);
		s7.setBgType(BGType.summer);
		s7.setStageName("7");
		List<HoleLocationInfo> holes7 = new ArrayList<HoleLocationInfo>();
		holes7.add(new HoleLocationInfo(getHoleX(84), getHoleY(247)));
		holes7.add(new HoleLocationInfo(getHoleX(240), getHoleY(247)));
		holes7.add(new HoleLocationInfo(getHoleX(400), getHoleY(247)));
		holes7.add(new HoleLocationInfo(getHoleX(240), getHoleY(425)));
		holes7.add(new HoleLocationInfo(getHoleX(100), getHoleY(587)));
		holes7.add(new HoleLocationInfo(getHoleX(370), getHoleY(587)));
		holes7.add(new HoleLocationInfo(getHoleX(240), getHoleY(690)));
		s7.setHoles(holes7);
		s7.setDwarfCount(46);
		s7.setDwarfInterval(1600);
		s7.setLocked(true);
		s7.setNormalPercentage(40);
		s7.setDoubleFemalePercentage(20);
		s7.setDoubleMalePercentage(40);
		s7.setBombPercentage(0);
		s7.setSilverPercentage(0);
		stageInfoLst.add(s7);

		// 8
		GameStageInfo s8 = new GameStageInfo();
		s8.setStageIndex(7);
		s8.setBgType(BGType.summer);
		s8.setStageName("8");
		List<HoleLocationInfo> holes8 = new ArrayList<HoleLocationInfo>();
		holes8.add(new HoleLocationInfo(getHoleX(169), getHoleY(230)));
		holes8.add(new HoleLocationInfo(getHoleX(310), getHoleY(230)));
		holes8.add(new HoleLocationInfo(getHoleX(240), getHoleY(360)));
		holes8.add(new HoleLocationInfo(getHoleX(67), getHoleY(474)));
		holes8.add(new HoleLocationInfo(getHoleX(411), getHoleY(474)));
		holes8.add(new HoleLocationInfo(getHoleX(238), getHoleY(531)));
		holes8.add(new HoleLocationInfo(getHoleX(240), getHoleY(685)));
		s8.setHoles(holes8);
		s8.setDwarfCount(46);
		s8.setDwarfInterval(1600);
		s8.setLocked(true);
		s8.setNormalPercentage(30);
		s8.setDoubleFemalePercentage(30);
		s8.setDoubleMalePercentage(40);
		s8.setBombPercentage(0);
		s8.setSilverPercentage(0);
		stageInfoLst.add(s8);

		// 9
		GameStageInfo s9 = new GameStageInfo();
		s9.setStageIndex(8);
		s9.setBgType(BGType.summer);
		s9.setStageName("9");
		List<HoleLocationInfo> holes9 = new ArrayList<HoleLocationInfo>();
		holes9.add(new HoleLocationInfo(getHoleX(88), getHoleY(250)));
		holes9.add(new HoleLocationInfo(getHoleX(240), getHoleY(250)));
		holes9.add(new HoleLocationInfo(getHoleX(396), getHoleY(250)));
		holes9.add(new HoleLocationInfo(getHoleX(88), getHoleY(447)));
		holes9.add(new HoleLocationInfo(getHoleX(240), getHoleY(447)));
		holes9.add(new HoleLocationInfo(getHoleX(396), getHoleY(447)));
		holes9.add(new HoleLocationInfo(getHoleX(240), getHoleY(644)));
		s9.setHoles(holes9);
		s9.setDwarfCount(46);
		s9.setDwarfInterval(1600);
		s9.setLocked(true);
		s9.setNormalPercentage(20);
		s9.setDoubleFemalePercentage(40);
		s9.setDoubleMalePercentage(30);
		s9.setBombPercentage(10);
		s9.setSilverPercentage(0);
		stageInfoLst.add(s9);

		// 10
		GameStageInfo s10 = new GameStageInfo();
		s10.setStageIndex(9);
		s10.setBgType(BGType.summer);
		s10.setStageName("10");
		List<HoleLocationInfo> holes10 = new ArrayList<HoleLocationInfo>();
		holes10.add(new HoleLocationInfo(getHoleX(177), getHoleY(200)));
		holes10.add(new HoleLocationInfo(getHoleX(378), getHoleY(229)));
		holes10.add(new HoleLocationInfo(getHoleX(90), getHoleY(323)));
		holes10.add(new HoleLocationInfo(getHoleX(288), getHoleY(352)));
		holes10.add(new HoleLocationInfo(getHoleX(90), getHoleY(534)));
		holes10.add(new HoleLocationInfo(getHoleX(291), getHoleY(494)));
		holes10.add(new HoleLocationInfo(getHoleX(192), getHoleY(689)));
		holes10.add(new HoleLocationInfo(getHoleX(393), getHoleY(656)));
		s10.setHoles(holes10);
		s10.setDwarfCount(46);
		s10.setDwarfInterval(1600);
		s10.setLocked(true);
		s10.setNormalPercentage(30);
		s10.setDoubleFemalePercentage(30);
		s10.setDoubleMalePercentage(30);
		s10.setBombPercentage(10);
		s10.setSilverPercentage(0);
		stageInfoLst.add(s10);

		// 11
		GameStageInfo s11 = new GameStageInfo();
		s11.setStageIndex(10);
		s11.setBgType(BGType.autumn);
		s11.setStageName("11");
		List<HoleLocationInfo> holes11 = new ArrayList<HoleLocationInfo>();
		holes11.add(new HoleLocationInfo(getHoleX(103), getHoleY(200)));
		holes11.add(new HoleLocationInfo(getHoleX(286), getHoleY(200)));
		holes11.add(new HoleLocationInfo(getHoleX(204), getHoleY(352)));
		holes11.add(new HoleLocationInfo(getHoleX(387), getHoleY(352)));
		holes11.add(new HoleLocationInfo(getHoleX(103), getHoleY(509)));
		holes11.add(new HoleLocationInfo(getHoleX(286), getHoleY(509)));
		holes11.add(new HoleLocationInfo(getHoleX(204), getHoleY(659)));
		holes11.add(new HoleLocationInfo(getHoleX(387), getHoleY(659)));
		s11.setHoles(holes11);
		s11.setDwarfCount(50);
		s11.setDwarfInterval(1600);
		s11.setLocked(true);
		s11.setNormalPercentage(50);
		s11.setDoubleFemalePercentage(17);
		s11.setDoubleMalePercentage(20);
		s11.setBombPercentage(3);
		s11.setSilverPercentage(10);
		stageInfoLst.add(s11);

		// 12
		GameStageInfo s12 = new GameStageInfo();
		s12.setStageIndex(11);
		s12.setBgType(BGType.autumn);
		s12.setStageName("12");
		List<HoleLocationInfo> holes12 = new ArrayList<HoleLocationInfo>();
		holes12.add(new HoleLocationInfo(getHoleX(103), getHoleY(200)));
		holes12.add(new HoleLocationInfo(getHoleX(382), getHoleY(200)));
		holes12.add(new HoleLocationInfo(getHoleX(240), getHoleY(293)));
		holes12.add(new HoleLocationInfo(getHoleX(103), getHoleY(419)));
		holes12.add(new HoleLocationInfo(getHoleX(382), getHoleY(419)));
		holes12.add(new HoleLocationInfo(getHoleX(237), getHoleY(506)));
		holes12.add(new HoleLocationInfo(getHoleX(133), getHoleY(650)));
		holes12.add(new HoleLocationInfo(getHoleX(334), getHoleY(650)));
		s12.setHoles(holes12);
		s12.setDwarfCount(50);
		s12.setDwarfInterval(1510);
		s12.setLocked(true);
		s12.setNormalPercentage(25);
		s12.setDoubleFemalePercentage(20);
		s12.setDoubleMalePercentage(40);
		s12.setBombPercentage(5);
		s12.setSilverPercentage(10);
		stageInfoLst.add(s12);

		// 13
		GameStageInfo s13 = new GameStageInfo();
		s13.setStageIndex(12);
		s13.setBgType(BGType.autumn);
		s13.setStageName("13");
		List<HoleLocationInfo> holes13 = new ArrayList<HoleLocationInfo>();
		holes13.add(new HoleLocationInfo(getHoleX(105), getHoleY(197)));
		holes13.add(new HoleLocationInfo(getHoleX(253), getHoleY(263)));
		holes13.add(new HoleLocationInfo(getHoleX(408), getHoleY(322)));
		holes13.add(new HoleLocationInfo(getHoleX(255), getHoleY(419)));
		holes13.add(new HoleLocationInfo(getHoleX(105), getHoleY(482)));
		holes13.add(new HoleLocationInfo(getHoleX(255), getHoleY(569)));
		holes13.add(new HoleLocationInfo(getHoleX(105), getHoleY(669)));
		holes13.add(new HoleLocationInfo(getHoleX(403), getHoleY(630)));
		s13.setHoles(holes13);
		s13.setDwarfCount(50);
		s13.setDwarfInterval(1600);
		s13.setLocked(true);
		s13.setNormalPercentage(30);
		s13.setDoubleFemalePercentage(35);
		s13.setDoubleMalePercentage(20);
		s13.setBombPercentage(5);
		s13.setSilverPercentage(10);
		stageInfoLst.add(s13);

		// 14
		GameStageInfo s14 = new GameStageInfo();
		s14.setStageIndex(13);
		s14.setBgType(BGType.autumn);
		s14.setStageName("14");
		List<HoleLocationInfo> holes14 = new ArrayList<HoleLocationInfo>();
		holes14.add(new HoleLocationInfo(getHoleX(240), getHoleY(200)));
		holes14.add(new HoleLocationInfo(getHoleX(141), getHoleY(301)));
		holes14.add(new HoleLocationInfo(getHoleX(330), getHoleY(301)));
		holes14.add(new HoleLocationInfo(getHoleX(75), getHoleY(444)));
		holes14.add(new HoleLocationInfo(getHoleX(405), getHoleY(444)));
		holes14.add(new HoleLocationInfo(getHoleX(240), getHoleY(550)));
		holes14.add(new HoleLocationInfo(getHoleX(175), getHoleY(695)));
		holes14.add(new HoleLocationInfo(getHoleX(307), getHoleY(695)));
		s14.setHoles(holes14);
		s14.setDwarfCount(50);
		s14.setDwarfInterval(1600);
		s14.setLocked(true);
		s14.setNormalPercentage(25);
		s14.setDoubleFemalePercentage(25);
		s14.setDoubleMalePercentage(25);
		s14.setBombPercentage(10);
		s14.setSilverPercentage(15);
		stageInfoLst.add(s14);

		// 15
		GameStageInfo s15 = new GameStageInfo();
		s15.setStageIndex(14);
		s15.setBgType(BGType.autumn);
		s15.setStageName("15");
		List<HoleLocationInfo> holes15 = new ArrayList<HoleLocationInfo>();
		holes15.add(new HoleLocationInfo(getHoleX(240), getHoleY(200)));
		holes15.add(new HoleLocationInfo(getHoleX(141), getHoleY(301)));
		holes15.add(new HoleLocationInfo(getHoleX(330), getHoleY(301)));
		holes15.add(new HoleLocationInfo(getHoleX(75), getHoleY(444)));
		holes15.add(new HoleLocationInfo(getHoleX(405), getHoleY(444)));
		holes15.add(new HoleLocationInfo(getHoleX(240), getHoleY(550)));
		holes15.add(new HoleLocationInfo(getHoleX(175), getHoleY(695)));
		holes15.add(new HoleLocationInfo(getHoleX(307), getHoleY(695)));
		s15.setHoles(holes15);
		s15.setDwarfCount(50);
		s15.setDwarfInterval(1600);
		s15.setLocked(true);
		s15.setNormalPercentage(35);
		s15.setDoubleFemalePercentage(10);
		s15.setDoubleMalePercentage(40);
		s15.setBombPercentage(10);
		s15.setSilverPercentage(5);
		stageInfoLst.add(s15);

		// 16
		GameStageInfo s16 = new GameStageInfo();
		s16.setStageIndex(15);
		s16.setBgType(BGType.winter);
		s16.setStageName("16");
		List<HoleLocationInfo> holes16 = new ArrayList<HoleLocationInfo>();
		holes16.add(new HoleLocationInfo(getHoleX(66), getHoleY(196)));
		holes16.add(new HoleLocationInfo(getHoleX(240), getHoleY(218)));
		holes16.add(new HoleLocationInfo(getHoleX(406), getHoleY(196)));
		holes16.add(new HoleLocationInfo(getHoleX(66), getHoleY(422)));
		holes16.add(new HoleLocationInfo(getHoleX(240), getHoleY(383)));
		holes16.add(new HoleLocationInfo(getHoleX(406), getHoleY(422)));
		holes16.add(new HoleLocationInfo(getHoleX(99), getHoleY(675)));
		holes16.add(new HoleLocationInfo(getHoleX(319), getHoleY(587)));
		s16.setHoles(holes16);
		s16.setDwarfCount(50);
		s16.setDwarfInterval(1600);
		s16.setLocked(true);
		s16.setNormalPercentage(50);
		s16.setDoubleFemalePercentage(0);
		s16.setDoubleMalePercentage(0);
		s16.setBombPercentage(5);
		s16.setSilverPercentage(45);
		stageInfoLst.add(s16);

		// 17
		GameStageInfo s17 = new GameStageInfo();
		s17.setStageIndex(16);
		s17.setBgType(BGType.winter);
		s17.setStageName("17");
		List<HoleLocationInfo> holes17 = new ArrayList<HoleLocationInfo>();
		holes17.add(new HoleLocationInfo(getHoleX(85), getHoleY(268)));
		holes17.add(new HoleLocationInfo(getHoleX(240), getHoleY(217)));
		holes17.add(new HoleLocationInfo(getHoleX(403), getHoleY(268)));
		holes17.add(new HoleLocationInfo(getHoleX(240), getHoleY(383)));
		holes17.add(new HoleLocationInfo(getHoleX(85), getHoleY(468)));
		holes17.add(new HoleLocationInfo(getHoleX(403), getHoleY(468)));
		holes17.add(new HoleLocationInfo(getHoleX(240), getHoleY(569)));
		holes17.add(new HoleLocationInfo(getHoleX(406), getHoleY(671)));
		s17.setHoles(holes17);
		s17.setDwarfCount(60);
		s17.setDwarfInterval(1600);
		s17.setLocked(true);
		s17.setNormalPercentage(20);
		s17.setDoubleFemalePercentage(30);
		s17.setDoubleMalePercentage(5);
		s17.setBombPercentage(5);
		s17.setSilverPercentage(40);
		stageInfoLst.add(s17);

		// 18
		GameStageInfo s18 = new GameStageInfo();
		s18.setStageIndex(17);
		s18.setBgType(BGType.winter);
		s18.setStageName("18");
		List<HoleLocationInfo> holes18 = new ArrayList<HoleLocationInfo>();
		holes18.add(new HoleLocationInfo(getHoleX(84), getHoleY(263)));
		holes18.add(new HoleLocationInfo(getHoleX(240), getHoleY(224)));
		holes18.add(new HoleLocationInfo(getHoleX(403), getHoleY(263)));
		holes18.add(new HoleLocationInfo(getHoleX(186), getHoleY(389)));
		holes18.add(new HoleLocationInfo(getHoleX(321), getHoleY(510)));
		holes18.add(new HoleLocationInfo(getHoleX(84), getHoleY(645)));
		holes18.add(new HoleLocationInfo(getHoleX(240), getHoleY(690)));
		holes18.add(new HoleLocationInfo(getHoleX(406), getHoleY(645)));
		s18.setHoles(holes18);
		s18.setDwarfCount(60);
		s18.setDwarfInterval(1600);
		s18.setLocked(true);
		s18.setNormalPercentage(30);
		s18.setDoubleFemalePercentage(30);
		s18.setDoubleMalePercentage(15);
		s18.setBombPercentage(25);
		s18.setSilverPercentage(0);
		stageInfoLst.add(s18);

		// 19
		GameStageInfo s19 = new GameStageInfo();
		s19.setStageIndex(18);
		s19.setBgType(BGType.winter);
		s19.setStageName("19");
		List<HoleLocationInfo> holes19 = new ArrayList<HoleLocationInfo>();
		holes19.add(new HoleLocationInfo(getHoleX(99), getHoleY(263)));
		holes19.add(new HoleLocationInfo(getHoleX(253), getHoleY(229)));
		holes19.add(new HoleLocationInfo(getHoleX(405), getHoleY(203)));
		holes19.add(new HoleLocationInfo(getHoleX(184), getHoleY(389)));
		holes19.add(new HoleLocationInfo(getHoleX(304), getHoleY(467)));
		holes19.add(new HoleLocationInfo(getHoleX(406), getHoleY(566)));
		holes19.add(new HoleLocationInfo(getHoleX(235), getHoleY(614)));
		holes19.add(new HoleLocationInfo(getHoleX(85), getHoleY(654)));
		s19.setHoles(holes19);
		s19.setDwarfCount(60);
		s19.setDwarfInterval(1600);
		s19.setLocked(true);
		s19.setNormalPercentage(30);
		s19.setDoubleFemalePercentage(30);
		s19.setDoubleMalePercentage(15);
		s19.setBombPercentage(25);
		s19.setSilverPercentage(0);
		stageInfoLst.add(s19);

		// 20
		GameStageInfo s20 = new GameStageInfo();
		s20.setStageIndex(19);
		s20.setBgType(BGType.winter);
		s20.setStageName("20");
		List<HoleLocationInfo> holes20 = new ArrayList<HoleLocationInfo>();
		holes20.add(new HoleLocationInfo(getHoleX(99), getHoleY(193)));
		holes20.add(new HoleLocationInfo(getHoleX(255), getHoleY(230)));
		holes20.add(new HoleLocationInfo(getHoleX(418), getHoleY(266)));
		holes20.add(new HoleLocationInfo(getHoleX(255), getHoleY(383)));
		holes20.add(new HoleLocationInfo(getHoleX(100), getHoleY(444)));
		holes20.add(new HoleLocationInfo(getHoleX(253), getHoleY(540)));
		holes20.add(new HoleLocationInfo(getHoleX(418), getHoleY(581)));
		holes20.add(new HoleLocationInfo(getHoleX(255), getHoleY(710)));
		s20.setHoles(holes20);
		s20.setDwarfCount(60);
		s20.setDwarfInterval(1500);
		s20.setLocked(true);
		s20.setNormalPercentage(55);
		s20.setDoubleFemalePercentage(0);
		s20.setDoubleMalePercentage(35);
		s20.setBombPercentage(5);
		s20.setSilverPercentage(5);
		stageInfoLst.add(s20);

		// 21
		GameStageInfo s21 = new GameStageInfo();
		s21.setStageIndex(20);
		s21.setBgType(BGType.livingroom);
		s21.setStageName("21");
		List<HoleLocationInfo> holes21 = new ArrayList<HoleLocationInfo>();
		holes21.add(new HoleLocationInfo(getHoleX(73), getHoleY(190)));
		holes21.add(new HoleLocationInfo(getHoleX(255), getHoleY(227)));
		holes21.add(new HoleLocationInfo(getHoleX(418), getHoleY(266)));
		holes21.add(new HoleLocationInfo(getHoleX(174), getHoleY(395)));
		holes21.add(new HoleLocationInfo(getHoleX(334), getHoleY(458)));
		holes21.add(new HoleLocationInfo(getHoleX(78), getHoleY(579)));
		holes21.add(new HoleLocationInfo(getHoleX(232), getHoleY(642)));
		holes21.add(new HoleLocationInfo(getHoleX(400), getHoleY(681)));
		s21.setHoles(holes21);
		s21.setDwarfCount(62);
		s21.setDwarfInterval(1500);
		s21.setLocked(true);
		s21.setNormalPercentage(30);
		s21.setDoubleFemalePercentage(20);
		s21.setDoubleMalePercentage(30);
		s21.setBombPercentage(15);
		s21.setSilverPercentage(5);
		stageInfoLst.add(s21);

		// 22
		GameStageInfo s22 = new GameStageInfo();
		s22.setStageIndex(21);
		s22.setBgType(BGType.livingroom);
		s22.setStageName("22");
		List<HoleLocationInfo> holes22 = new ArrayList<HoleLocationInfo>();
		holes22.add(new HoleLocationInfo(getHoleX(84), getHoleY(190)));
		holes22.add(new HoleLocationInfo(getHoleX(240), getHoleY(235)));
		holes22.add(new HoleLocationInfo(getHoleX(412), getHoleY(272)));
		holes22.add(new HoleLocationInfo(getHoleX(312), getHoleY(395)));
		holes22.add(new HoleLocationInfo(getHoleX(181), getHoleY(470)));
		holes22.add(new HoleLocationInfo(getHoleX(66), getHoleY(557)));
		holes22.add(new HoleLocationInfo(getHoleX(234), getHoleY(620)));
		holes22.add(new HoleLocationInfo(getHoleX(399), getHoleY(683)));
		s22.setHoles(holes22);
		s22.setDwarfCount(62);
		s22.setDwarfInterval(1500);
		s22.setLocked(true);
		s22.setNormalPercentage(30);
		s22.setDoubleFemalePercentage(30);
		s22.setDoubleMalePercentage(20);
		s22.setBombPercentage(15);
		s22.setSilverPercentage(5);
		stageInfoLst.add(s22);

		// 23
		GameStageInfo s23 = new GameStageInfo();
		s23.setStageIndex(22);
		s23.setBgType(BGType.livingroom);
		s23.setStageName("23");
		List<HoleLocationInfo> holes23 = new ArrayList<HoleLocationInfo>();
		holes23.add(new HoleLocationInfo(getHoleX(66), getHoleY(295)));
		holes23.add(new HoleLocationInfo(getHoleX(240), getHoleY(227)));
		holes23.add(new HoleLocationInfo(getHoleX(415), getHoleY(295)));
		holes23.add(new HoleLocationInfo(getHoleX(153), getHoleY(437)));
		holes23.add(new HoleLocationInfo(getHoleX(333), getHoleY(437)));
		holes23.add(new HoleLocationInfo(getHoleX(240), getHoleY(528)));
		holes23.add(new HoleLocationInfo(getHoleX(85), getHoleY(626)));
		holes23.add(new HoleLocationInfo(getHoleX(397), getHoleY(626)));
		s23.setHoles(holes23);
		s23.setDwarfCount(62);
		s23.setDwarfInterval(1500);
		s23.setLocked(true);
		s23.setNormalPercentage(20);
		s23.setDoubleFemalePercentage(20);
		s23.setDoubleMalePercentage(30);
		s23.setBombPercentage(15);
		s23.setSilverPercentage(15);
		stageInfoLst.add(s23);

		// 24
		GameStageInfo s24 = new GameStageInfo();
		s24.setStageIndex(23);
		s24.setBgType(BGType.livingroom);
		s24.setStageName("24");
		List<HoleLocationInfo> holes24 = new ArrayList<HoleLocationInfo>();
		holes24.add(new HoleLocationInfo(getHoleX(175), getHoleY(226)));
		holes24.add(new HoleLocationInfo(getHoleX(300), getHoleY(226)));
		holes24.add(new HoleLocationInfo(getHoleX(175), getHoleY(379)));
		holes24.add(new HoleLocationInfo(getHoleX(300), getHoleY(379)));
		holes24.add(new HoleLocationInfo(getHoleX(103), getHoleY(536)));
		holes24.add(new HoleLocationInfo(getHoleX(388), getHoleY(536)));
		holes24.add(new HoleLocationInfo(getHoleX(175), getHoleY(660)));
		holes24.add(new HoleLocationInfo(getHoleX(300), getHoleY(660)));
		s24.setHoles(holes24);
		s24.setDwarfCount(62);
		s24.setDwarfInterval(1500);
		s24.setLocked(true);
		s24.setNormalPercentage(10);
		s24.setDoubleFemalePercentage(30);
		s24.setDoubleMalePercentage(30);
		s24.setBombPercentage(10);
		s24.setSilverPercentage(20);
		stageInfoLst.add(s24);

		// 25
		GameStageInfo s25 = new GameStageInfo();
		s25.setStageIndex(24);
		s25.setBgType(BGType.livingroom);
		s25.setStageName("25");
		List<HoleLocationInfo> holes25 = new ArrayList<HoleLocationInfo>();
		holes25.add(new HoleLocationInfo(getHoleX(177), getHoleY(256)));
		holes25.add(new HoleLocationInfo(getHoleX(301), getHoleY(256)));
		holes25.add(new HoleLocationInfo(getHoleX(61), getHoleY(434)));
		holes25.add(new HoleLocationInfo(getHoleX(177), getHoleY(434)));
		holes25.add(new HoleLocationInfo(getHoleX(301), getHoleY(434)));
		holes25.add(new HoleLocationInfo(getHoleX(420), getHoleY(434)));
		holes25.add(new HoleLocationInfo(getHoleX(175), getHoleY(627)));
		holes25.add(new HoleLocationInfo(getHoleX(301), getHoleY(627)));
		s25.setHoles(holes25);
		s25.setDwarfCount(65);
		s25.setDwarfInterval(700);
		s25.setLocked(true);
		s25.setNormalPercentage(100);
		s25.setDoubleFemalePercentage(0);
		s25.setDoubleMalePercentage(0);
		s25.setBombPercentage(0);
		s25.setSilverPercentage(0);
		stageInfoLst.add(s25);

		// 26
		GameStageInfo s26 = new GameStageInfo();
		s26.setStageIndex(25);
		s26.setBgType(BGType.tarmac);
		s26.setStageName("26");
		List<HoleLocationInfo> holes26 = new ArrayList<HoleLocationInfo>();
		holes26.add(new HoleLocationInfo(getHoleX(90), getHoleY(215)));
		holes26.add(new HoleLocationInfo(getHoleX(250), getHoleY(215)));
		holes26.add(new HoleLocationInfo(getHoleX(400), getHoleY(215)));
		holes26.add(new HoleLocationInfo(getHoleX(90), getHoleY(380)));
		holes26.add(new HoleLocationInfo(getHoleX(400), getHoleY(380)));
		holes26.add(new HoleLocationInfo(getHoleX(247), getHoleY(470)));
		holes26.add(new HoleLocationInfo(getHoleX(88), getHoleY(650)));
		holes26.add(new HoleLocationInfo(getHoleX(247), getHoleY(650)));
		holes26.add(new HoleLocationInfo(getHoleX(400), getHoleY(650)));
		s26.setHoles(holes26);
		s26.setDwarfCount(65);
		s26.setDwarfInterval(1400);
		s26.setLocked(true);
		s26.setNormalPercentage(20);
		s26.setDoubleFemalePercentage(30);
		s26.setDoubleMalePercentage(0);
		s26.setBombPercentage(0);
		s26.setSilverPercentage(50);
		stageInfoLst.add(s26);

		// 27
		GameStageInfo s27 = new GameStageInfo();
		s27.setStageIndex(26);
		s27.setBgType(BGType.tarmac);
		s27.setStageName("27");
		List<HoleLocationInfo> holes27 = new ArrayList<HoleLocationInfo>();
		holes27.add(new HoleLocationInfo(getHoleX(88), getHoleY(199)));
		holes27.add(new HoleLocationInfo(getHoleX(88), getHoleY(356)));
		holes27.add(new HoleLocationInfo(getHoleX(88), getHoleY(515)));
		holes27.add(new HoleLocationInfo(getHoleX(88), getHoleY(670)));
		holes27.add(new HoleLocationInfo(getHoleX(240), getHoleY(299)));
		holes27.add(new HoleLocationInfo(getHoleX(400), getHoleY(199)));
		holes27.add(new HoleLocationInfo(getHoleX(400), getHoleY(356)));
		holes27.add(new HoleLocationInfo(getHoleX(400), getHoleY(515)));
		holes27.add(new HoleLocationInfo(getHoleX(400), getHoleY(670)));
		s27.setHoles(holes27);
		s27.setDwarfCount(65);
		s27.setDwarfInterval(1400);
		s27.setLocked(true);
		s27.setNormalPercentage(20);
		s27.setDoubleFemalePercentage(30);
		s27.setDoubleMalePercentage(40);
		s27.setBombPercentage(10);
		s27.setSilverPercentage(0);
		stageInfoLst.add(s27);

		// 28
		GameStageInfo s28 = new GameStageInfo();
		s28.setStageIndex(27);
		s28.setBgType(BGType.tarmac);
		s28.setStageName("28");
		List<HoleLocationInfo> holes28 = new ArrayList<HoleLocationInfo>();
		holes28.add(new HoleLocationInfo(getHoleX(187), getHoleY(203)));
		holes28.add(new HoleLocationInfo(getHoleX(300), getHoleY(203)));
		holes28.add(new HoleLocationInfo(getHoleX(90), getHoleY(278)));
		holes28.add(new HoleLocationInfo(getHoleX(399), getHoleY(278)));
		holes28.add(new HoleLocationInfo(getHoleX(90), getHoleY(444)));
		holes28.add(new HoleLocationInfo(getHoleX(399), getHoleY(444)));
		holes28.add(new HoleLocationInfo(getHoleX(187), getHoleY(545)));
		holes28.add(new HoleLocationInfo(getHoleX(300), getHoleY(545)));
		holes28.add(new HoleLocationInfo(getHoleX(240), getHoleY(708)));
		s28.setHoles(holes28);
		s28.setDwarfCount(65);
		s28.setDwarfInterval(1400);
		s28.setLocked(true);
		s28.setNormalPercentage(10);
		s28.setDoubleFemalePercentage(30);
		s28.setDoubleMalePercentage(30);
		s28.setBombPercentage(20);
		s28.setSilverPercentage(10);
		stageInfoLst.add(s28);

		// 29
		GameStageInfo s29 = new GameStageInfo();
		s29.setStageIndex(28);
		s29.setBgType(BGType.tarmac);
		s29.setStageName("29");
		List<HoleLocationInfo> holes29 = new ArrayList<HoleLocationInfo>();
		holes29.add(new HoleLocationInfo(getHoleX(267), getHoleY(247)));
		holes29.add(new HoleLocationInfo(getHoleX(412), getHoleY(247)));
		holes29.add(new HoleLocationInfo(getHoleX(154), getHoleY(340)));
		holes29.add(new HoleLocationInfo(getHoleX(55), getHoleY(447)));
		holes29.add(new HoleLocationInfo(getHoleX(268), getHoleY(447)));
		holes29.add(new HoleLocationInfo(getHoleX(412), getHoleY(447)));
		holes29.add(new HoleLocationInfo(getHoleX(154), getHoleY(584)));
		holes29.add(new HoleLocationInfo(getHoleX(267), getHoleY(675)));
		holes29.add(new HoleLocationInfo(getHoleX(411), getHoleY(675)));
		s29.setHoles(holes29);
		s29.setDwarfCount(70);
		s29.setDwarfInterval(1400);
		s29.setLocked(true);
		s29.setNormalPercentage(15);
		s29.setDoubleFemalePercentage(30);
		s29.setDoubleMalePercentage(30);
		s29.setBombPercentage(15);
		s29.setSilverPercentage(10);
		stageInfoLst.add(s29);

		// 30
		GameStageInfo s30 = new GameStageInfo();
		s30.setStageIndex(29);
		s30.setBgType(BGType.tarmac);
		s30.setStageName("30");
		List<HoleLocationInfo> holes30 = new ArrayList<HoleLocationInfo>();
		holes30.add(new HoleLocationInfo(getHoleX(100), getHoleY(188)));
		holes30.add(new HoleLocationInfo(getHoleX(380), getHoleY(188)));
		holes30.add(new HoleLocationInfo(getHoleX(100), getHoleY(347)));
		holes30.add(new HoleLocationInfo(getHoleX(380), getHoleY(347)));
		holes30.add(new HoleLocationInfo(getHoleX(100), getHoleY(516)));
		holes30.add(new HoleLocationInfo(getHoleX(380), getHoleY(416)));
		holes30.add(new HoleLocationInfo(getHoleX(100), getHoleY(687)));
		holes30.add(new HoleLocationInfo(getHoleX(240), getHoleY(687)));
		holes30.add(new HoleLocationInfo(getHoleX(380), getHoleY(687)));
		s30.setHoles(holes30);
		s30.setDwarfCount(80);
		s30.setDwarfInterval(1300);
		s30.setLocked(true);
		s30.setNormalPercentage(18);
		s30.setDoubleFemalePercentage(22);
		s30.setDoubleMalePercentage(30);
		s30.setBombPercentage(10);
		s30.setSilverPercentage(20);
		stageInfoLst.add(s30);
	}

	private void initUnlimit() {
		umlimitStage = new GameStageInfo();
		umlimitStage.setStageIndex(0);
		umlimitStage.setBgType(BGType.spring);
		umlimitStage.setStageName("无尽模式");
		List<HoleLocationInfo> holetestStage = new ArrayList<HoleLocationInfo>();
		holetestStage.add(new HoleLocationInfo(getHoleX(85), getHoleY(253)));
		holetestStage.add(new HoleLocationInfo(getHoleX(240), getHoleY(253)));
		holetestStage.add(new HoleLocationInfo(getHoleX(393), getHoleY(253)));
		holetestStage.add(new HoleLocationInfo(getHoleX(154), getHoleY(403)));
		holetestStage.add(new HoleLocationInfo(getHoleX(328), getHoleY(403)));
		holetestStage.add(new HoleLocationInfo(getHoleX(240), getHoleY(546)));
		holetestStage.add(new HoleLocationInfo(getHoleX(85), getHoleY(611)));
		holetestStage.add(new HoleLocationInfo(getHoleX(409), getHoleY(611)));
		holetestStage.add(new HoleLocationInfo(getHoleX(240), getHoleY(704)));
		umlimitStage.setHoles(holetestStage);
		umlimitStage.setDwarfCount(10);
		umlimitStage.setDwarfInterval(1200);
		umlimitStage.setLocked(false);
		umlimitStage.setNormalPercentage(25);
		umlimitStage.setDoubleFemalePercentage(30);
		umlimitStage.setDoubleMalePercentage(30);
		umlimitStage.setBombPercentage(5);
		umlimitStage.setSilverPercentage(10);
	}

	private float getHoleX(float px) {
		return px / 480.0f;
	}

	private float getHoleY(float py) {
		return 1.0f - py / 800.0f;
	}

}
